
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>灵活运用JS开发技巧 · 记录技术文档内容</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="zhengyuliang">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-sectionx/sectionx.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="编写高质量可维护的代码：一目了然的注释.html" />
    
    
    <link rel="prev" href="异步神器Async-await介绍与填坑.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        <li class="header">CSS</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../CSS/18种CSS命名和书写规范.html">
            
                <a href="../CSS/18种CSS命名和书写规范.html">
            
                    
                    18种CSS命名和书写规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../CSS/灵活运用CSS开发技巧.html">
            
                <a href="../CSS/灵活运用CSS开发技巧.html">
            
                    
                    灵活运用CSS开发技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../CSS/自适应 flex grid.html">
            
                <a href="../CSS/自适应 flex grid.html">
            
                    
                    自适应 Flex Grid
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">HTML</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../HTML/浏览器里的本地数据库：IndexedDB.html">
            
                <a href="../HTML/浏览器里的本地数据库：IndexedDB.html">
            
                    
                    浏览器里的本地数据库：IndexedDB
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Vue</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../Vue/7个有用的Vue开发技巧.html">
            
                <a href="../Vue/7个有用的Vue开发技巧.html">
            
                    
                    7个有用的Vue开发技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="../Vue/Vue this.$router.push、replace、go的区别.html">
            
                <a href="../Vue/Vue this.$router.push、replace、go的区别.html">
            
                    
                    Vue This.$Router.Push、Replace、Go的区别
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="../Vue/Vue 的父组件和子组件生命周期钩子函数执行顺序？.html">
            
                <a href="../Vue/Vue 的父组件和子组件生命周期钩子函数执行顺序？.html">
            
                    
                    Vue 的父组件和子组件生命周期钩子函数执行顺序？
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="../Vue/Vue.set和this.$set应用的场景.html">
            
                <a href="../Vue/Vue.set和this.$set应用的场景.html">
            
                    
                    Vue.Set和This.$Set应用的场景
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="../Vue/vue高级技巧.html">
            
                <a href="../Vue/vue高级技巧.html">
            
                    
                    Vue高级技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="../Vue/从 0 开始手把手带你搭建一套规范的 Vue3.x 项目工程环境.html">
            
                <a href="../Vue/从 0 开始手把手带你搭建一套规范的 Vue3.x 项目工程环境.html">
            
                    
                    从 0 开始手把手带你搭建一套规范的 Vue3.X 项目工程环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="../Vue/浅析 vue-router 源码和动态路由权限分配.html">
            
                <a href="../Vue/浅析 vue-router 源码和动态路由权限分配.html">
            
                    
                    浅析 Vue Router 源码和动态路由权限分配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8" data-path="../Vue/父组件监听到子组件的生命周期.html">
            
                <a href="../Vue/父组件监听到子组件的生命周期.html">
            
                    
                    父组件监听到子组件的生命周期
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.9" data-path="../Vue/理解Vue.mixin，利用Vue.mixin正确的偷懒.html">
            
                <a href="../Vue/理解Vue.mixin，利用Vue.mixin正确的偷懒.html">
            
                    
                    理解Vue.Mixin，利用Vue.Mixin正确的偷懒
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">JavaScript</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="5个技巧让你更好的编写 JavaScript(ES6">
            
                <span>
            
                    
                    5个技巧让你更好的编写 JavaScript(ES6) 中条件语句
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="5种常见函数的写法和调用方式.html">
            
                <a href="5种常见函数的写法和调用方式.html">
            
                    
                    5种常见函数的写法和调用方式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="7道javascript题，让你理解基本的javascript.html">
            
                <a href="7道javascript题，让你理解基本的javascript.html">
            
                    
                    7道Javascript题，让你理解基本的Javascript
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="Array.from(">
            
                <span>
            
                    
                    Array.From() 五个超好用的用途
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="ES6汇总资料.html">
            
                <a href="ES6汇总资料.html">
            
                    
                    ES6汇总资料
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.6" data-path="JS开发必须知道的41个技巧.html">
            
                <a href="JS开发必须知道的41个技巧.html">
            
                    
                    JS开发必须知道的41个技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.7" data-path="JavaScript之防抖Debounce和节流Throttle.html">
            
                <a href="JavaScript之防抖Debounce和节流Throttle.html">
            
                    
                    JavaScript之防抖Debounce和节流Throttle
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.8" data-path="JavaScript数组求并集，交集和差集.html">
            
                <a href="JavaScript数组求并集，交集和差集.html">
            
                    
                    JavaScript数组求并集，交集和差集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.9" data-path="JavaScript的优雅写法.html">
            
                <a href="JavaScript的优雅写法.html">
            
                    
                    JavaScript的优雅写法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.10" data-path="axios知识点.html">
            
                <a href="axios知识点.html">
            
                    
                    Axios知识点
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.11" data-path="javascript核心知识.html">
            
                <a href="javascript核心知识.html">
            
                    
                    Javascript核心知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.12" data-path="this、apply、call、bind.html">
            
                <a href="this、apply、call、bind.html">
            
                    
                    This、Apply、Call、Bind
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.13" data-path="前端js常用的60余种工具方法.html">
            
                <a href="前端js常用的60余种工具方法.html">
            
                    
                    前端Js常用的60余种工具方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.14" data-path="前端异常的捕获与处理.html">
            
                <a href="前端异常的捕获与处理.html">
            
                    
                    前端异常的捕获与处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.15" data-path="在 JavaScript 中交换值的 10 种方法.html">
            
                <a href="在 JavaScript 中交换值的 10 种方法.html">
            
                    
                    在 JavaScript 中交换值的 10 种方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.16" data-path="常用的前端JavaScript方法封装.html">
            
                <a href="常用的前端JavaScript方法封装.html">
            
                    
                    常用的前端JavaScript方法封装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.17" data-path="异步神器Async-await介绍与填坑.html">
            
                <a href="异步神器Async-await介绍与填坑.html">
            
                    
                    异步神器Async Await介绍与填坑
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="4.18" data-path="灵活运用JS开发技巧.html">
            
                <a href="灵活运用JS开发技巧.html">
            
                    
                    灵活运用JS开发技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.19" data-path="编写高质量可维护的代码：一目了然的注释.html">
            
                <a href="编写高质量可维护的代码：一目了然的注释.html">
            
                    
                    编写高质量可维护的代码：一目了然的注释
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.20" data-path="编写高质量可维护的代码：优化逻辑判断.html">
            
                <a href="编写高质量可维护的代码：优化逻辑判断.html">
            
                    
                    编写高质量可维护的代码：优化逻辑判断
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.21" data-path="编写高质量可维护的代码：优雅命名.html">
            
                <a href="编写高质量可维护的代码：优雅命名.html">
            
                    
                    编写高质量可维护的代码：优雅命名
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.22" data-path="编写高质量可维护的代码：数据建模.html">
            
                <a href="编写高质量可维护的代码：数据建模.html">
            
                    
                    编写高质量可维护的代码：数据建模
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Life Exp</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../life_exp/告别平庸的15个小方法.html">
            
                <a href="../life_exp/告别平庸的15个小方法.html">
            
                    
                    告别平庸的15个小方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="../life_exp/日志记录.html">
            
                <a href="../life_exp/日志记录.html">
            
                    
                    日志记录
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="../life_exp/程序员的发展方向.html">
            
                <a href="../life_exp/程序员的发展方向.html">
            
                    
                    程序员的发展方向
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="../message/">
            
                <a href="../message/">
            
                    
                    Message
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Technology</li>
        
        
    
        <li class="chapter " data-level="6.1" data-path="../technology/WebSocket.html">
            
                <a href="../technology/WebSocket.html">
            
                    
                    WebSocket
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="../technology/npm常用命令大全.html">
            
                <a href="../technology/npm常用命令大全.html">
            
                    
                    Npm常用命令大全
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="../technology/智能照明项目说明.html">
            
                <a href="../technology/智能照明项目说明.html">
            
                    
                    智能照明项目说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="../technology/规范化git的提交信息.html">
            
                <a href="../technology/规范化git的提交信息.html">
            
                    
                    规范化Git的提交信息
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Tutorial</li>
        
        
    
        <li class="chapter " data-level="7.1" data-path="../tutorial/Esmap地图详解.html">
            
                <a href="../tutorial/Esmap地图详解.html">
            
                    
                    Esmap地图详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="../tutorial/npm镜像切换.html">
            
                <a href="../tutorial/npm镜像切换.html">
            
                    
                    Npm镜像切换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.3" data-path="../tutorial/发布npm的教程.html">
            
                <a href="../tutorial/发布npm的教程.html">
            
                    
                    发布Npm的教程
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >灵活运用JS开发技巧</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <html><head></head><body><div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><ul><li><span class="title-icon "></span><a href="#&#x7075;&#x6D3B;&#x8FD0;&#x7528;js&#x5F00;&#x53D1;&#x6280;&#x5DE7;"><b>1.1. </b>&#x7075;&#x6D3B;&#x8FD0;&#x7528;JS&#x5F00;&#x53D1;&#x6280;&#x5DE7;</a></li><ul><li><span class="title-icon "></span><a href="#&#x524D;&#x8A00;"><b>1.1.1. </b>&#x524D;&#x8A00;</a></li><li><span class="title-icon "></span><a href="#&#x76EE;&#x5F55;"><b>1.1.2. </b>&#x76EE;&#x5F55;</a></li><li><span class="title-icon "></span><a href="#string-skill"><b>1.1.3. </b>String Skill</a></li><li><span class="title-icon "></span><a href="#number-skill"><b>1.1.4. </b>Number Skill</a></li><li><span class="title-icon "></span><a href="#boolean-skill"><b>1.1.5. </b>Boolean Skill</a></li><li><span class="title-icon "></span><a href="#array-skill"><b>1.1.6. </b>Array Skill</a></li><li><span class="title-icon "></span><a href="#object-skill"><b>1.1.7. </b>Object Skill</a></li><li><span class="title-icon "></span><a href="#function-skill"><b>1.1.8. </b>Function Skill</a></li><li><span class="title-icon "></span><a href="#dom-skill"><b>1.1.9. </b>DOM Skill</a></li><li><span class="title-icon "></span><a href="#&#x603B;&#x7ED3;"><b>1.1.10. </b>&#x603B;&#x7ED3;</a></li></ul></ul></ul></div><a href="#" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h2 id="&#x7075;&#x6D3B;&#x8FD0;&#x7528;js&#x5F00;&#x53D1;&#x6280;&#x5DE7;"><a name="&#x7075;&#x6D3B;&#x8FD0;&#x7528;js&#x5F00;&#x53D1;&#x6280;&#x5DE7;" class="anchor-navigation-ex-anchor" href="#&#x7075;&#x6D3B;&#x8FD0;&#x7528;js&#x5F00;&#x53D1;&#x6280;&#x5DE7;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1. &#x7075;&#x6D3B;&#x8FD0;&#x7528;JS&#x5F00;&#x53D1;&#x6280;&#x5DE7;</h2>
<h3 id="&#x524D;&#x8A00;"><a name="&#x524D;&#x8A00;" class="anchor-navigation-ex-anchor" href="#&#x524D;&#x8A00;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.1. &#x524D;&#x8A00;</h3>
<p>&#x4F55;&#x4E3A;&#x6280;&#x5DE7;&#xFF0C;&#x610F;&#x6307;&#x8868;&#x73B0;&#x5728;&#x6587;&#x5B66;&#x3001;&#x5DE5;&#x827A;&#x3001;&#x4F53;&#x80B2;&#x7B49;&#x65B9;&#x9762;&#x7684;&#x5DE7;&#x5999;&#x6280;&#x80FD;&#x3002;&#x4EE3;&#x7801;&#x4F5C;&#x4E3A;&#x4E00;&#x95E8;&#x73B0;&#x4EE3;&#x9AD8;&#x7EA7;&#x5DE5;&#x827A;&#xFF0C;&#x63A8;&#x52A8;&#x7740;&#x4EBA;&#x7C7B;&#x79D1;&#x5B66;&#x6280;&#x672F;&#x7684;&#x53D1;&#x5C55;&#xFF0C;&#x540C;&#x65F6;&#x72B9;&#x5982;&#x6587;&#x5B57;&#x4E00;&#x6837;&#x627F;&#x6258;&#x7740;&#x4EBA;&#x7C7B;&#x6587;&#x5316;&#x7684;&#x8FDB;&#x6B65;&#x3002;</p>
<p>&#x6BCF;&#x5199;&#x597D;&#x4E00;&#x7BC7;&#x6587;&#x7AE0;&#xFF0C;&#x90FD;&#x4F1A;&#x4F7F;&#x7528;&#x5927;&#x91CF;&#x7684;&#x5199;&#x4F5C;&#x6280;&#x5DE7;&#x3002;<code>&#x70D8;&#x6258;&#x3001;&#x6E32;&#x67D3;&#x3001;&#x60AC;&#x5FF5;&#x3001;&#x94FA;&#x57AB;&#x3001;&#x7167;&#x5E94;&#x3001;&#x4F0F;&#x7B14;&#x3001;&#x8054;&#x60F3;&#x3001;&#x60F3;&#x8C61;&#x3001;&#x6291;&#x626C;&#x7ED3;&#x5408;&#x3001;&#x70B9;&#x9762;&#x7ED3;&#x5408;&#x3001;&#x52A8;&#x9759;&#x7ED3;&#x5408;&#x3001;&#x53D9;&#x8BAE;&#x7ED3;&#x5408;&#x3001;&#x60C5;&#x666F;&#x4EA4;&#x878D;&#x3001;&#x9996;&#x5C3E;&#x547C;&#x5E94;&#x3001;&#x886C;&#x6258;&#x5BF9;&#x6BD4;&#x3001;&#x767D;&#x63CF;&#x7EC6;&#x63CF;&#x3001;&#x6BD4;&#x55BB;&#x8C61;&#x5F81;&#x3001;&#x501F;&#x53E4;&#x8BBD;&#x4ECA;&#x3001;&#x5352;&#x7AE0;&#x663E;&#x5FD7;&#x3001;&#x627F;&#x4E0A;&#x542F;&#x4E0B;&#x3001;&#x5F00;&#x95E8;&#x89C1;&#x5C71;&#x3001;&#x52A8;&#x9759;&#x76F8;&#x886C;&#x3001;&#x865A;&#x5B9E;&#x76F8;&#x751F;&#x3001;&#x5B9E;&#x5199;&#x865A;&#x5199;&#x3001;&#x6258;&#x7269;&#x5BD3;&#x610F;&#x3001;&#x548F;&#x7269;&#x6292;&#x60C5;</code>&#x7B49;&#xFF0C;&#x8FD9;&#x4E9B;&#x5E94;&#x8BE5;&#x90FD;&#x662F;&#x6211;&#x4EEC;&#x4ECE;&#x5C0F;&#x5230;&#x5927;&#x5199;&#x6587;&#x7AE0;&#x800C;&#x63A5;&#x89E6;&#x5230;&#x7684;&#x5199;&#x4F5C;&#x6280;&#x5DE7;&#x3002;</p>
<p>&#x4F5C;&#x4E3A;&#x7A0B;&#x5E8F;&#x733F;&#x7684;&#x6211;&#x4EEC;&#xFF0C;&#x5199;&#x4EE3;&#x7801;&#x540C;&#x6837;&#x4E5F;&#x9700;&#x8981;&#x5927;&#x91CF;&#x7684;&#x5199;&#x4F5C;&#x6280;&#x5DE7;&#x3002;&#x4E00;&#x4EFD;&#x826F;&#x597D;&#x7684;&#x4EE3;&#x7801;&#x80FD;&#x8BA9;&#x4EBA;&#x8033;&#x76EE;&#x4E00;&#x65B0;&#xFF0C;&#x8BA9;&#x4EBA;&#x5BB9;&#x6613;&#x7406;&#x89E3;&#xFF0C;&#x8BA9;&#x4EBA;&#x8212;&#x670D;&#x81EA;&#x7136;&#xFF0C;&#x540C;&#x65F6;&#x4E5F;&#x8BA9;&#x81EA;&#x5DF1;&#x6210;&#x5C31;&#x611F;&#x6EE1;&#x6EE1;(&#x54C8;&#x54C8;&#xFF0C;&#x8FD9;&#x4E2A;&#x624D;&#x662F;&#x91CD;&#x70B9;)&#x3002;&#x56E0;&#x6B64;&#xFF0C;&#x6211;&#x6574;&#x7406;&#x4E0B;&#x4E09;&#x5E74;&#x6765;&#x81EA;&#x5DF1;&#x4F7F;&#x7528;&#x5230;&#x7684;&#x4E00;&#x4E9B;<strong>JS&#x5F00;&#x53D1;&#x6280;&#x5DE7;</strong>&#xFF0C;&#x5E0C;&#x671B;&#x80FD;&#x8BA9;&#x4F60;&#x5199;&#x51FA;&#x8033;&#x76EE;&#x4E00;&#x65B0;&#x3001;&#x5BB9;&#x6613;&#x7406;&#x89E3;&#x3001;&#x8212;&#x670D;&#x81EA;&#x7136;&#x7684;&#x4EE3;&#x7801;&#x3002;</p>
<blockquote>
<p>&#x4EE5;&#x4E0B;&#x6F14;&#x793A;&#x5168;&#x662F;ES6&#x7248;&#x672C;&#x7684;&#x4E66;&#x5199;&#xFF0C;&#x5728;<code>Webpack</code>&#x548C;<code>Babel</code>&#x7684;&#x52A0;&#x6301;&#x4E0B;&#x5C31;&#x4E0D;&#x80FD;&#x597D;&#x597D;&#x5199;ES6&#x5417;&#xFF0C;&#x8FD8;&#x5199;&#x4EC0;&#x4E48;ES3&#x548C;ES5&#x5462;&#xFF0C;&#x66F4;&#x522B;&#x7BA1;&#x90A3;&#x5F31;&#x667A;&#x7684;IE&#x6D4F;&#x89C8;&#x5668;&#x4E86;&#xFF0C;IE&#x6D4F;&#x89C8;&#x5668;&#x90FD;&#x5FEB;&#x88AB;&#x6DD8;&#x6C70;&#x4E86;&#xFF0C;<strong>Microsoft</strong>&#x90FD;&#x5BA3;&#x5E03;&#x653E;&#x5F03;&#x4F7F;&#x7528;&#x81EA;&#x7814;&#x7684;&#x6D4F;&#x89C8;&#x5668;&#x5185;&#x6838;&#x800C;&#x4F7F;&#x7528;<strong>Google</strong>&#x5F00;&#x6E90;&#x7684;<code>Chromium</code>&#x5185;&#x6838;&#x4E86;&#x3002;</p>
</blockquote>
<h3 id="&#x76EE;&#x5F55;"><a name="&#x76EE;&#x5F55;" class="anchor-navigation-ex-anchor" href="#&#x76EE;&#x5F55;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.2. &#x76EE;&#x5F55;</h3>
<p>&#x65E2;&#x7136;&#x5199;&#x6587;&#x7AE0;&#x6709;&#x8FD9;&#x4E48;&#x591A;&#x7684;&#x5199;&#x4F5C;&#x6280;&#x5DE7;&#xFF0C;&#x90A3;&#x4E48;&#x6211;&#x4E5F;&#x9700;&#x8981;&#x5BF9;<strong>JS&#x5F00;&#x53D1;&#x6280;&#x5DE7;</strong>&#x6574;&#x7406;&#x4E00;&#x4E0B;&#xFF0C;&#x8D77;&#x4E2A;&#x6613;&#x8BB0;&#x7684;&#x540D;&#x5B57;&#x3002;</p>
<ul>
<li><strong>String Skill</strong>&#xFF1A;&#x5B57;&#x7B26;&#x4E32;&#x6280;&#x5DE7;</li>
<li><strong>Number Skill</strong>&#xFF1A;&#x6570;&#x503C;&#x6280;&#x5DE7;</li>
<li><strong>Boolean Skill</strong>&#xFF1A;&#x5E03;&#x5C14;&#x6280;&#x5DE7;</li>
<li><strong>Array Skill</strong>&#xFF1A;&#x6570;&#x7EC4;&#x6280;&#x5DE7;</li>
<li><strong>Object Skill</strong>&#xFF1A;&#x5BF9;&#x8C61;&#x6280;&#x5DE7;</li>
<li><strong>Function Skill</strong>&#xFF1A;&#x51FD;&#x6570;&#x6280;&#x5DE7;</li>
<li><strong>DOM Skill</strong>&#xFF1A;DOM&#x6280;&#x5DE7;</li>
</ul>
<p>&#x5907;&#x6CE8;</p>
<ul>
<li>&#x4EE3;&#x7801;&#x53EA;&#x4F5C;&#x6F14;&#x793A;&#x7528;&#x9014;&#xFF0C;&#x4E0D;&#x4F1A;&#x8BE6;&#x7EC6;&#x8BF4;&#x660E;ES6&#x8BED;&#x6CD5;</li>
<li>&#x5982;&#x6709;&#x4E0D;&#x660E;&#x767D;&#x7684;&#x8BED;&#x6CD5;&#x95EE;&#x9898;&#x8BF7;&#x53C2;&#x8003;&#x962E;&#x4E00;&#x5CF0;&#x8001;&#x5E08;&#x7684;<a href="https://es6.ruanyifeng.com/" target="_blank">&#x300A;ES6&#x6807;&#x51C6;&#x5165;&#x95E8;&#x300B;</a></li>
<li><a href="https://es6.ruanyifeng.com/" target="_blank">&#x300A;ES6&#x6807;&#x51C6;&#x5165;&#x95E8;&#x300B;</a>&#x4E00;&#x76F4;&#x4FDD;&#x6301;&#x66F4;&#x65B0;&#xFF0C;&#x5EFA;&#x8BAE;&#x6536;&#x85CF;&#xFF0C;&#x5E73;&#x65F6;&#x67E5;&#x770B;</li>
</ul>
<h3 id="string-skill"><a name="string-skill" class="anchor-navigation-ex-anchor" href="#string-skill"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.3. String Skill</h3>
<h5 id="&#x5BF9;&#x6BD4;&#x65F6;&#x95F4;"><a name="&#x5BF9;&#x6BD4;&#x65F6;&#x95F4;" class="anchor-navigation-ex-anchor" href="#&#x5BF9;&#x6BD4;&#x65F6;&#x95F4;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5BF9;&#x6BD4;&#x65F6;&#x95F4;</h5>
<blockquote>
<p>&#x65F6;&#x95F4;&#x4E2A;&#x4F4D;&#x6570;&#x5F62;&#x5F0F;&#x9700;&#x8865;0</p>
</blockquote>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> time1 = <span class="hljs-string">&quot;2019-02-14 21:00:00&quot;</span>;
<span class="hljs-keyword">const</span> time2 = <span class="hljs-string">&quot;2019-05-01 09:00:00&quot;</span>;
<span class="hljs-keyword">const</span> overtime = time1 &gt; time2;
<span class="hljs-comment">// overtime =&gt; false</span>
</code></pre>
<h5 id="&#x683C;&#x5F0F;&#x5316;&#x91D1;&#x94B1;"><a name="&#x683C;&#x5F0F;&#x5316;&#x91D1;&#x94B1;" class="anchor-navigation-ex-anchor" href="#&#x683C;&#x5F0F;&#x5316;&#x91D1;&#x94B1;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x683C;&#x5F0F;&#x5316;&#x91D1;&#x94B1;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> ThousandNum = <span class="hljs-function"><span class="hljs-params">num</span> =&gt;</span> num.toString().replace(<span class="hljs-regexp">/\B(?=(\d{3})+(?!\d))/g</span>, <span class="hljs-string">&quot;,&quot;</span>);
<span class="hljs-keyword">const</span> money = ThousandNum(<span class="hljs-number">20190214</span>);
<span class="hljs-comment">// money =&gt; &quot;20,190,214&quot;</span>
</code></pre>
<h5 id="&#x751F;&#x6210;&#x968F;&#x673A;id"><a name="&#x751F;&#x6210;&#x968F;&#x673A;id" class="anchor-navigation-ex-anchor" href="#&#x751F;&#x6210;&#x968F;&#x673A;id"><i class="fa fa-link" aria-hidden="true"></i></a>&#x751F;&#x6210;&#x968F;&#x673A;ID</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> RandomId = <span class="hljs-function"><span class="hljs-params">len</span> =&gt;</span> <span class="hljs-built_in">Math</span>.random().toString(<span class="hljs-number">36</span>).substr(<span class="hljs-number">3</span>, len);
<span class="hljs-keyword">const</span> id = RandomId(<span class="hljs-number">10</span>);
<span class="hljs-comment">// id =&gt; &quot;jg7zpgiqva&quot;</span>
</code></pre>
<h5 id="&#x751F;&#x6210;&#x968F;&#x673A;hex&#x8272;&#x503C;"><a name="&#x751F;&#x6210;&#x968F;&#x673A;hex&#x8272;&#x503C;" class="anchor-navigation-ex-anchor" href="#&#x751F;&#x6210;&#x968F;&#x673A;hex&#x8272;&#x503C;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x751F;&#x6210;&#x968F;&#x673A;HEX&#x8272;&#x503C;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> RandomColor = <span class="hljs-function"><span class="hljs-params">()</span> =&gt;</span> <span class="hljs-string">&quot;#&quot;</span> + <span class="hljs-built_in">Math</span>.floor(<span class="hljs-built_in">Math</span>.random() * <span class="hljs-number">0xffffff</span>).toString(<span class="hljs-number">16</span>).padEnd(<span class="hljs-number">6</span>, <span class="hljs-string">&quot;0&quot;</span>);
<span class="hljs-keyword">const</span> color = RandomColor();
<span class="hljs-comment">// color =&gt; &quot;#f03665&quot;</span>
</code></pre>
<h5 id="&#x751F;&#x6210;&#x661F;&#x7EA7;&#x8BC4;&#x5206;"><a name="&#x751F;&#x6210;&#x661F;&#x7EA7;&#x8BC4;&#x5206;" class="anchor-navigation-ex-anchor" href="#&#x751F;&#x6210;&#x661F;&#x7EA7;&#x8BC4;&#x5206;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x751F;&#x6210;&#x661F;&#x7EA7;&#x8BC4;&#x5206;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> StartScore = <span class="hljs-function"><span class="hljs-params">rate</span> =&gt;</span> <span class="hljs-string">&quot;&#x2605;&#x2605;&#x2605;&#x2605;&#x2605;&#x2606;&#x2606;&#x2606;&#x2606;&#x2606;&quot;</span>.slice(<span class="hljs-number">5</span> - rate, <span class="hljs-number">10</span> - rate);
<span class="hljs-keyword">const</span> start = StartScore(<span class="hljs-number">3</span>);
<span class="hljs-comment">// start =&gt; &quot;&#x2605;&#x2605;&#x2605;&quot;</span>
</code></pre>
<h5 id="&#x64CD;&#x4F5C;url&#x67E5;&#x8BE2;&#x53C2;&#x6570;"><a name="&#x64CD;&#x4F5C;url&#x67E5;&#x8BE2;&#x53C2;&#x6570;" class="anchor-navigation-ex-anchor" href="#&#x64CD;&#x4F5C;url&#x67E5;&#x8BE2;&#x53C2;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x64CD;&#x4F5C;URL&#x67E5;&#x8BE2;&#x53C2;&#x6570;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> params = <span class="hljs-keyword">new</span> URLSearchParams(location.search.replace(<span class="hljs-regexp">/\?/ig</span>, <span class="hljs-string">&quot;&quot;</span>)); <span class="hljs-comment">// location.search = &quot;?name=young&amp;sex=male&quot;</span>
params.has(<span class="hljs-string">&quot;young&quot;</span>); <span class="hljs-comment">// true</span>
params.get(<span class="hljs-string">&quot;sex&quot;</span>); <span class="hljs-comment">// &quot;male&quot;</span>
</code></pre>
<h3 id="number-skill"><a name="number-skill" class="anchor-navigation-ex-anchor" href="#number-skill"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.4. Number Skill</h3>
<h5 id="&#x53D6;&#x6574;"><a name="&#x53D6;&#x6574;" class="anchor-navigation-ex-anchor" href="#&#x53D6;&#x6574;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x53D6;&#x6574;</h5>
<blockquote>
<p>&#x4EE3;&#x66FF;&#x6B63;&#x6570;&#x7684;<code>Math.floor()</code>&#xFF0C;&#x4EE3;&#x66FF;&#x8D1F;&#x6570;&#x7684;<code>Math.ceil()</code></p>
</blockquote>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> num1 = ~~ <span class="hljs-number">1.69</span>;
<span class="hljs-keyword">const</span> num2 = <span class="hljs-number">1.69</span> | <span class="hljs-number">0</span>;
<span class="hljs-keyword">const</span> num3 = <span class="hljs-number">1.69</span> &gt;&gt; <span class="hljs-number">0</span>;
<span class="hljs-comment">// num1 num2 num3 =&gt; 1 1 1</span>
</code></pre>
<h5 id="&#x8865;&#x96F6;"><a name="&#x8865;&#x96F6;" class="anchor-navigation-ex-anchor" href="#&#x8865;&#x96F6;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x8865;&#x96F6;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> FillZero = <span class="hljs-function">(<span class="hljs-params">num, len</span>) =&gt;</span> num.toString().padStart(len, <span class="hljs-string">&quot;0&quot;</span>);
<span class="hljs-keyword">const</span> num = FillZero(<span class="hljs-number">169</span>, <span class="hljs-number">5</span>);
<span class="hljs-comment">// num =&gt; &quot;00169&quot;</span>
</code></pre>
<h5 id="&#x8F6C;&#x6570;&#x503C;"><a name="&#x8F6C;&#x6570;&#x503C;" class="anchor-navigation-ex-anchor" href="#&#x8F6C;&#x6570;&#x503C;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x8F6C;&#x6570;&#x503C;</h5>
<blockquote>
<p>&#x53EA;&#x5BF9;<code>null&#x3001;&quot;&quot;&#x3001;false&#x3001;&#x6570;&#x503C;&#x5B57;&#x7B26;&#x4E32;</code>&#x6709;&#x6548;</p>
</blockquote>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> num1 = +<span class="hljs-literal">null</span>;
<span class="hljs-keyword">const</span> num2 = +<span class="hljs-string">&quot;&quot;</span>;
<span class="hljs-keyword">const</span> num3 = +<span class="hljs-literal">false</span>;
<span class="hljs-keyword">const</span> num4 = +<span class="hljs-string">&quot;169&quot;</span>;
<span class="hljs-comment">// num1 num2 num3 num4 =&gt; 0 0 0 169</span>
</code></pre>
<h5 id="&#x65F6;&#x95F4;&#x6233;"><a name="&#x65F6;&#x95F4;&#x6233;" class="anchor-navigation-ex-anchor" href="#&#x65F6;&#x95F4;&#x6233;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x65F6;&#x95F4;&#x6233;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> timestamp = +<span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(<span class="hljs-string">&quot;2019-02-14&quot;</span>);
<span class="hljs-comment">// timestamp =&gt; 1550102400000</span>
</code></pre>
<h5 id="&#x7CBE;&#x786E;&#x5C0F;&#x6570;"><a name="&#x7CBE;&#x786E;&#x5C0F;&#x6570;" class="anchor-navigation-ex-anchor" href="#&#x7CBE;&#x786E;&#x5C0F;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x7CBE;&#x786E;&#x5C0F;&#x6570;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> RoundNum = <span class="hljs-function">(<span class="hljs-params">num, decimal</span>) =&gt;</span> <span class="hljs-built_in">Math</span>.round(num * <span class="hljs-number">10</span> ** decimal) / <span class="hljs-number">10</span> ** decimal;
<span class="hljs-keyword">const</span> num = RoundNum(<span class="hljs-number">1.69</span>, <span class="hljs-number">1</span>);
<span class="hljs-comment">// num =&gt; 1.7</span>
</code></pre>
<h5 id="&#x5224;&#x65AD;&#x5947;&#x5076;"><a name="&#x5224;&#x65AD;&#x5947;&#x5076;" class="anchor-navigation-ex-anchor" href="#&#x5224;&#x65AD;&#x5947;&#x5076;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5224;&#x65AD;&#x5947;&#x5076;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> OddEven = <span class="hljs-function"><span class="hljs-params">num</span> =&gt;</span> !!(num &amp; <span class="hljs-number">1</span>) ? <span class="hljs-string">&quot;odd&quot;</span> : <span class="hljs-string">&quot;even&quot;</span>;
<span class="hljs-keyword">const</span> num = OddEven(<span class="hljs-number">2</span>);
<span class="hljs-comment">// num =&gt; &quot;even&quot;</span>
</code></pre>
<h5 id="&#x53D6;&#x6700;&#x5C0F;&#x6700;&#x5927;&#x503C;"><a name="&#x53D6;&#x6700;&#x5C0F;&#x6700;&#x5927;&#x503C;" class="anchor-navigation-ex-anchor" href="#&#x53D6;&#x6700;&#x5C0F;&#x6700;&#x5927;&#x503C;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x53D6;&#x6700;&#x5C0F;&#x6700;&#x5927;&#x503C;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr = [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>];
<span class="hljs-keyword">const</span> min = <span class="hljs-built_in">Math</span>.min(...arr);
<span class="hljs-keyword">const</span> max = <span class="hljs-built_in">Math</span>.max(...arr);
<span class="hljs-comment">// min max =&gt; 0 2</span>
</code></pre>
<h5 id="&#x751F;&#x6210;&#x8303;&#x56F4;&#x968F;&#x673A;&#x6570;"><a name="&#x751F;&#x6210;&#x8303;&#x56F4;&#x968F;&#x673A;&#x6570;" class="anchor-navigation-ex-anchor" href="#&#x751F;&#x6210;&#x8303;&#x56F4;&#x968F;&#x673A;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x751F;&#x6210;&#x8303;&#x56F4;&#x968F;&#x673A;&#x6570;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> RandomNum = <span class="hljs-function">(<span class="hljs-params">min, max</span>) =&gt;</span> <span class="hljs-built_in">Math</span>.floor(<span class="hljs-built_in">Math</span>.random() * (max - min + <span class="hljs-number">1</span>)) + min;
<span class="hljs-keyword">const</span> num = RandomNum(<span class="hljs-number">1</span>, <span class="hljs-number">10</span>);
</code></pre>
<h3 id="boolean-skill"><a name="boolean-skill" class="anchor-navigation-ex-anchor" href="#boolean-skill"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.5. Boolean Skill</h3>
<h5 id="&#x77ED;&#x8DEF;&#x8FD0;&#x7B97;&#x7B26;"><a name="&#x77ED;&#x8DEF;&#x8FD0;&#x7B97;&#x7B26;" class="anchor-navigation-ex-anchor" href="#&#x77ED;&#x8DEF;&#x8FD0;&#x7B97;&#x7B26;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x77ED;&#x8DEF;&#x8FD0;&#x7B97;&#x7B26;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> a = d &amp;&amp; <span class="hljs-number">1</span>; <span class="hljs-comment">// &#x6EE1;&#x8DB3;&#x6761;&#x4EF6;&#x8D4B;&#x503C;&#xFF1A;&#x53D6;&#x5047;&#x8FD0;&#x7B97;&#xFF0C;&#x4ECE;&#x5DE6;&#x5230;&#x53F3;&#x4F9D;&#x6B21;&#x5224;&#x65AD;&#xFF0C;&#x9047;&#x5230;&#x5047;&#x503C;&#x8FD4;&#x56DE;&#x5047;&#x503C;&#xFF0C;&#x540E;&#x9762;&#x4E0D;&#x518D;&#x6267;&#x884C;&#xFF0C;&#x5426;&#x5219;&#x8FD4;&#x56DE;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x771F;&#x503C;</span>
<span class="hljs-keyword">const</span> b = d || <span class="hljs-number">1</span>; <span class="hljs-comment">// &#x9ED8;&#x8BA4;&#x8D4B;&#x503C;&#xFF1A;&#x53D6;&#x771F;&#x8FD0;&#x7B97;&#xFF0C;&#x4ECE;&#x5DE6;&#x5230;&#x53F3;&#x4F9D;&#x6B21;&#x5224;&#x65AD;&#xFF0C;&#x9047;&#x5230;&#x771F;&#x503C;&#x8FD4;&#x56DE;&#x771F;&#x503C;&#xFF0C;&#x540E;&#x9762;&#x4E0D;&#x518D;&#x6267;&#x884C;&#xFF0C;&#x5426;&#x5219;&#x8FD4;&#x56DE;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x5047;&#x503C;</span>
<span class="hljs-keyword">const</span> c = !d; <span class="hljs-comment">// &#x53D6;&#x5047;&#x8D4B;&#x503C;&#xFF1A;&#x5355;&#x4E2A;&#x8868;&#x8FBE;&#x5F0F;&#x8F6C;&#x6362;&#x4E3A;true&#x5219;&#x8FD4;&#x56DE;false&#xFF0C;&#x5426;&#x5219;&#x8FD4;&#x56DE;true</span>
</code></pre>
<h5 id="&#x5224;&#x65AD;&#x6570;&#x636E;&#x7C7B;&#x578B;"><a name="&#x5224;&#x65AD;&#x6570;&#x636E;&#x7C7B;&#x578B;" class="anchor-navigation-ex-anchor" href="#&#x5224;&#x65AD;&#x6570;&#x636E;&#x7C7B;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5224;&#x65AD;&#x6570;&#x636E;&#x7C7B;&#x578B;</h5>
<blockquote>
<p>&#x53EF;&#x5224;&#x65AD;&#x7C7B;&#x578B;&#xFF1A;undefined&#x3001;null&#x3001;string&#x3001;number&#x3001;boolean&#x3001;array&#x3001;object&#x3001;symbol&#x3001;date&#x3001;regexp&#x3001;function&#x3001;asyncfunction&#x3001;arguments&#x3001;set&#x3001;map&#x3001;weakset&#x3001;weakmap</p>
</blockquote>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">DataType</span>(<span class="hljs-params">tgt, type</span>) </span>{
    <span class="hljs-keyword">const</span> dataType = <span class="hljs-built_in">Object</span>.prototype.toString.call(tgt).replace(<span class="hljs-regexp">/\[object (\w+)\]/</span>, <span class="hljs-string">&quot;$1&quot;</span>).toLowerCase();
    <span class="hljs-keyword">return</span> type ? dataType === type : dataType;
}
DataType(<span class="hljs-string">&quot;young&quot;</span>); <span class="hljs-comment">// &quot;string&quot;</span>
DataType(<span class="hljs-number">20190214</span>); <span class="hljs-comment">// &quot;number&quot;</span>
DataType(<span class="hljs-literal">true</span>); <span class="hljs-comment">// &quot;boolean&quot;</span>
DataType([], <span class="hljs-string">&quot;array&quot;</span>); <span class="hljs-comment">// true</span>
DataType({}, <span class="hljs-string">&quot;array&quot;</span>); <span class="hljs-comment">// false</span>
</code></pre>
<h5 id="&#x662F;&#x5426;&#x4E3A;&#x7A7A;&#x6570;&#x7EC4;"><a name="&#x662F;&#x5426;&#x4E3A;&#x7A7A;&#x6570;&#x7EC4;" class="anchor-navigation-ex-anchor" href="#&#x662F;&#x5426;&#x4E3A;&#x7A7A;&#x6570;&#x7EC4;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x662F;&#x5426;&#x4E3A;&#x7A7A;&#x6570;&#x7EC4;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr = [];
<span class="hljs-keyword">const</span> flag = <span class="hljs-built_in">Array</span>.isArray(arr) &amp;&amp; !arr.length;
<span class="hljs-comment">// flag =&gt; true</span>
</code></pre>
<h5 id="&#x662F;&#x5426;&#x4E3A;&#x7A7A;&#x5BF9;&#x8C61;"><a name="&#x662F;&#x5426;&#x4E3A;&#x7A7A;&#x5BF9;&#x8C61;" class="anchor-navigation-ex-anchor" href="#&#x662F;&#x5426;&#x4E3A;&#x7A7A;&#x5BF9;&#x8C61;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x662F;&#x5426;&#x4E3A;&#x7A7A;&#x5BF9;&#x8C61;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> obj = {};
<span class="hljs-keyword">const</span> flag = DataType(obj, <span class="hljs-string">&quot;object&quot;</span>) &amp;&amp; !<span class="hljs-built_in">Object</span>.keys(obj).length;
<span class="hljs-comment">// flag =&gt; true</span>
</code></pre>
<h5 id="&#x6EE1;&#x8DB3;&#x6761;&#x4EF6;&#x65F6;&#x6267;&#x884C;"><a name="&#x6EE1;&#x8DB3;&#x6761;&#x4EF6;&#x65F6;&#x6267;&#x884C;" class="anchor-navigation-ex-anchor" href="#&#x6EE1;&#x8DB3;&#x6761;&#x4EF6;&#x65F6;&#x6267;&#x884C;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6EE1;&#x8DB3;&#x6761;&#x4EF6;&#x65F6;&#x6267;&#x884C;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> flagA = <span class="hljs-literal">true</span>; <span class="hljs-comment">// &#x6761;&#x4EF6;A</span>
<span class="hljs-keyword">const</span> flagB = <span class="hljs-literal">false</span>; <span class="hljs-comment">// &#x6761;&#x4EF6;B</span>
(flagA || flagB) &amp;&amp; Func(); <span class="hljs-comment">// &#x6EE1;&#x8DB3;A&#x6216;B&#x65F6;&#x6267;&#x884C;</span>
(flagA || !flagB) &amp;&amp; Func(); <span class="hljs-comment">// &#x6EE1;&#x8DB3;A&#x6216;&#x4E0D;&#x6EE1;&#x8DB3;B&#x65F6;&#x6267;&#x884C;</span>
flagA &amp;&amp; flagB &amp;&amp; Func(); <span class="hljs-comment">// &#x540C;&#x65F6;&#x6EE1;&#x8DB3;A&#x548C;B&#x65F6;&#x6267;&#x884C;</span>
flagA &amp;&amp; !flagB &amp;&amp; Func(); <span class="hljs-comment">// &#x6EE1;&#x8DB3;A&#x4E14;&#x4E0D;&#x6EE1;&#x8DB3;B&#x65F6;&#x6267;&#x884C;</span>
</code></pre>
<h5 id="&#x4E3A;&#x975E;&#x5047;&#x503C;&#x65F6;&#x6267;&#x884C;"><a name="&#x4E3A;&#x975E;&#x5047;&#x503C;&#x65F6;&#x6267;&#x884C;" class="anchor-navigation-ex-anchor" href="#&#x4E3A;&#x975E;&#x5047;&#x503C;&#x65F6;&#x6267;&#x884C;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E3A;&#x975E;&#x5047;&#x503C;&#x65F6;&#x6267;&#x884C;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> flag = <span class="hljs-literal">false</span>; <span class="hljs-comment">// undefined&#x3001;null&#x3001;&quot;&quot;&#x3001;0&#x3001;false&#x3001;NaN</span>
!flag &amp;&amp; Func();
</code></pre>
<h5 id="&#x6570;&#x7EC4;&#x4E0D;&#x4E3A;&#x7A7A;&#x65F6;&#x6267;&#x884C;"><a name="&#x6570;&#x7EC4;&#x4E0D;&#x4E3A;&#x7A7A;&#x65F6;&#x6267;&#x884C;" class="anchor-navigation-ex-anchor" href="#&#x6570;&#x7EC4;&#x4E0D;&#x4E3A;&#x7A7A;&#x65F6;&#x6267;&#x884C;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6570;&#x7EC4;&#x4E0D;&#x4E3A;&#x7A7A;&#x65F6;&#x6267;&#x884C;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr = [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>];
arr.length &amp;&amp; Func();
</code></pre>
<h5 id="&#x5BF9;&#x8C61;&#x4E0D;&#x4E3A;&#x7A7A;&#x65F6;&#x6267;&#x884C;"><a name="&#x5BF9;&#x8C61;&#x4E0D;&#x4E3A;&#x7A7A;&#x65F6;&#x6267;&#x884C;" class="anchor-navigation-ex-anchor" href="#&#x5BF9;&#x8C61;&#x4E0D;&#x4E3A;&#x7A7A;&#x65F6;&#x6267;&#x884C;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5BF9;&#x8C61;&#x4E0D;&#x4E3A;&#x7A7A;&#x65F6;&#x6267;&#x884C;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> obj = { <span class="hljs-attr">a</span>: <span class="hljs-number">0</span>, <span class="hljs-attr">b</span>: <span class="hljs-number">1</span>, <span class="hljs-attr">c</span>: <span class="hljs-number">2</span> };
<span class="hljs-built_in">Object</span>.keys(obj).length &amp;&amp; Func();
</code></pre>
<h5 id="&#x51FD;&#x6570;&#x9000;&#x51FA;&#x4EE3;&#x66FF;&#x6761;&#x4EF6;&#x5206;&#x652F;&#x9000;&#x51FA;"><a name="&#x51FD;&#x6570;&#x9000;&#x51FA;&#x4EE3;&#x66FF;&#x6761;&#x4EF6;&#x5206;&#x652F;&#x9000;&#x51FA;" class="anchor-navigation-ex-anchor" href="#&#x51FD;&#x6570;&#x9000;&#x51FA;&#x4EE3;&#x66FF;&#x6761;&#x4EF6;&#x5206;&#x652F;&#x9000;&#x51FA;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x51FD;&#x6570;&#x9000;&#x51FA;&#x4EE3;&#x66FF;&#x6761;&#x4EF6;&#x5206;&#x652F;&#x9000;&#x51FA;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">if</span> (flag) {
    Func();
    <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
}
<span class="hljs-comment">// &#x6362;&#x6210;</span>
<span class="hljs-keyword">if</span> (flag) {
    <span class="hljs-keyword">return</span> Func();
}
</code></pre>
<h5 id="switchcase&#x4F7F;&#x7528;&#x533A;&#x95F4;"><a name="switchcase&#x4F7F;&#x7528;&#x533A;&#x95F4;" class="anchor-navigation-ex-anchor" href="#switchcase&#x4F7F;&#x7528;&#x533A;&#x95F4;"><i class="fa fa-link" aria-hidden="true"></i></a>switch/case&#x4F7F;&#x7528;&#x533A;&#x95F4;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> age = <span class="hljs-number">26</span>;
<span class="hljs-keyword">switch</span> (<span class="hljs-literal">true</span>) {
    <span class="hljs-keyword">case</span> <span class="hljs-built_in">isNaN</span>(age):
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;not a number&quot;</span>);
        <span class="hljs-keyword">break</span>;
    <span class="hljs-keyword">case</span> (age &lt; <span class="hljs-number">18</span>):
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;under age&quot;</span>);
        <span class="hljs-keyword">break</span>;
    <span class="hljs-keyword">case</span> (age &gt;= <span class="hljs-number">18</span>):
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;adult&quot;</span>);
        <span class="hljs-keyword">break</span>;
    <span class="hljs-keyword">default</span>:
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;please set your age&quot;</span>);
        <span class="hljs-keyword">break</span>;
}
</code></pre>
<h3 id="array-skill"><a name="array-skill" class="anchor-navigation-ex-anchor" href="#array-skill"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.6. Array Skill</h3>
<h5 id="&#x514B;&#x9686;&#x6570;&#x7EC4;"><a name="&#x514B;&#x9686;&#x6570;&#x7EC4;" class="anchor-navigation-ex-anchor" href="#&#x514B;&#x9686;&#x6570;&#x7EC4;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x514B;&#x9686;&#x6570;&#x7EC4;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> _arr = [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>];
<span class="hljs-keyword">const</span> arr = [..._arr];
<span class="hljs-comment">// arr =&gt; [0, 1, 2]</span>
</code></pre>
<h5 id="&#x5408;&#x5E76;&#x6570;&#x7EC4;"><a name="&#x5408;&#x5E76;&#x6570;&#x7EC4;" class="anchor-navigation-ex-anchor" href="#&#x5408;&#x5E76;&#x6570;&#x7EC4;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5408;&#x5E76;&#x6570;&#x7EC4;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr1 = [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>];
<span class="hljs-keyword">const</span> arr2 = [<span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>];
<span class="hljs-keyword">const</span> arr = [...arr1, ...arr2];
<span class="hljs-comment">// arr =&gt; [0, 1, 2, 3, 4, 5];</span>
</code></pre>
<h5 id="&#x53BB;&#x91CD;&#x6570;&#x7EC4;"><a name="&#x53BB;&#x91CD;&#x6570;&#x7EC4;" class="anchor-navigation-ex-anchor" href="#&#x53BB;&#x91CD;&#x6570;&#x7EC4;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x53BB;&#x91CD;&#x6570;&#x7EC4;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr = [...new <span class="hljs-built_in">Set</span>([<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-literal">null</span>, <span class="hljs-literal">null</span>])];
<span class="hljs-comment">// arr =&gt; [0, 1, null]</span>
</code></pre>
<h5 id="&#x6DF7;&#x6DC6;&#x6570;&#x7EC4;"><a name="&#x6DF7;&#x6DC6;&#x6570;&#x7EC4;" class="anchor-navigation-ex-anchor" href="#&#x6DF7;&#x6DC6;&#x6570;&#x7EC4;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6DF7;&#x6DC6;&#x6570;&#x7EC4;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr = [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>].slice().sort(<span class="hljs-function"><span class="hljs-params">()</span> =&gt;</span> <span class="hljs-built_in">Math</span>.random() - <span class="hljs-number">.5</span>);
<span class="hljs-comment">// arr =&gt; [3, 4, 0, 5, 1, 2]</span>
</code></pre>
<h5 id="&#x6E05;&#x7A7A;&#x6570;&#x7EC4;"><a name="&#x6E05;&#x7A7A;&#x6570;&#x7EC4;" class="anchor-navigation-ex-anchor" href="#&#x6E05;&#x7A7A;&#x6570;&#x7EC4;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6E05;&#x7A7A;&#x6570;&#x7EC4;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr = [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>];
arr.length = <span class="hljs-number">0</span>;
<span class="hljs-comment">// arr =&gt; []</span>
</code></pre>
<h5 id="&#x622A;&#x65AD;&#x6570;&#x7EC4;"><a name="&#x622A;&#x65AD;&#x6570;&#x7EC4;" class="anchor-navigation-ex-anchor" href="#&#x622A;&#x65AD;&#x6570;&#x7EC4;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x622A;&#x65AD;&#x6570;&#x7EC4;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr = [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>];
arr.length = <span class="hljs-number">2</span>;
<span class="hljs-comment">// arr =&gt; [0, 1]</span>
</code></pre>
<h5 id="&#x4EA4;&#x6362;&#x8D4B;&#x503C;"><a name="&#x4EA4;&#x6362;&#x8D4B;&#x503C;" class="anchor-navigation-ex-anchor" href="#&#x4EA4;&#x6362;&#x8D4B;&#x503C;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4EA4;&#x6362;&#x8D4B;&#x503C;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> a = <span class="hljs-number">0</span>;
<span class="hljs-keyword">let</span> b = <span class="hljs-number">1</span>;
[a, b] = [b, a];
<span class="hljs-comment">// a b =&gt; 1 0</span>
</code></pre>
<h5 id="&#x8FC7;&#x6EE4;&#x7A7A;&#x503C;"><a name="&#x8FC7;&#x6EE4;&#x7A7A;&#x503C;" class="anchor-navigation-ex-anchor" href="#&#x8FC7;&#x6EE4;&#x7A7A;&#x503C;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x8FC7;&#x6EE4;&#x7A7A;&#x503C;</h5>
<blockquote>
<p>&#x7A7A;&#x503C;&#xFF1A;undefined&#x3001;null&#x3001;&quot;&quot;&#x3001;0&#x3001;false&#x3001;NaN</p>
</blockquote>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr = [<span class="hljs-literal">undefined</span>, <span class="hljs-literal">null</span>, <span class="hljs-string">&quot;&quot;</span>, <span class="hljs-number">0</span>, <span class="hljs-literal">false</span>, <span class="hljs-literal">NaN</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>].filter(<span class="hljs-built_in">Boolean</span>);
<span class="hljs-comment">// arr =&gt; [1, 2]</span>
</code></pre>
<h5 id="&#x5F02;&#x6B65;&#x7D2F;&#x8BA1;"><a name="&#x5F02;&#x6B65;&#x7D2F;&#x8BA1;" class="anchor-navigation-ex-anchor" href="#&#x5F02;&#x6B65;&#x7D2F;&#x8BA1;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5F02;&#x6B65;&#x7D2F;&#x8BA1;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Func</span>(<span class="hljs-params">deps</span>) </span>{
    <span class="hljs-keyword">return</span> deps.reduce(<span class="hljs-keyword">async</span>(t, v) =&gt; {
        <span class="hljs-keyword">const</span> dep = <span class="hljs-keyword">await</span> t;
        <span class="hljs-keyword">const</span> version = <span class="hljs-keyword">await</span> Todo(v);
        dep[v] = version;
        <span class="hljs-keyword">return</span> dep;
    }, <span class="hljs-built_in">Promise</span>.resolve({}));
}
<span class="hljs-keyword">const</span> result = <span class="hljs-keyword">await</span> Func(); <span class="hljs-comment">// &#x9700;&#x5728;async&#x5305;&#x56F4;&#x4E0B;&#x4F7F;&#x7528;</span>
</code></pre>
<h5 id="&#x6570;&#x7EC4;&#x9996;&#x90E8;&#x63D2;&#x5165;&#x6210;&#x5458;"><a name="&#x6570;&#x7EC4;&#x9996;&#x90E8;&#x63D2;&#x5165;&#x6210;&#x5458;" class="anchor-navigation-ex-anchor" href="#&#x6570;&#x7EC4;&#x9996;&#x90E8;&#x63D2;&#x5165;&#x6210;&#x5458;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6570;&#x7EC4;&#x9996;&#x90E8;&#x63D2;&#x5165;&#x6210;&#x5458;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> arr = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>]; <span class="hljs-comment">// &#x4EE5;&#x4E0B;&#x65B9;&#x6CD5;&#x4EFB;&#x9009;&#x4E00;&#x79CD;</span>
arr.unshift(<span class="hljs-number">0</span>);
arr = [<span class="hljs-number">0</span>].concat(arr);
arr = [<span class="hljs-number">0</span>, ...arr];
<span class="hljs-comment">// arr =&gt; [0, 1, 2]</span>
</code></pre>
<h5 id="&#x6570;&#x7EC4;&#x5C3E;&#x90E8;&#x63D2;&#x5165;&#x6210;&#x5458;"><a name="&#x6570;&#x7EC4;&#x5C3E;&#x90E8;&#x63D2;&#x5165;&#x6210;&#x5458;" class="anchor-navigation-ex-anchor" href="#&#x6570;&#x7EC4;&#x5C3E;&#x90E8;&#x63D2;&#x5165;&#x6210;&#x5458;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6570;&#x7EC4;&#x5C3E;&#x90E8;&#x63D2;&#x5165;&#x6210;&#x5458;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> arr = [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>]; <span class="hljs-comment">// &#x4EE5;&#x4E0B;&#x65B9;&#x6CD5;&#x4EFB;&#x9009;&#x4E00;&#x79CD;</span>
arr.push(<span class="hljs-number">2</span>);
arr.concat(<span class="hljs-number">2</span>);
arr[arr.length] = <span class="hljs-number">2</span>;
arr = [...arr, <span class="hljs-number">2</span>];
<span class="hljs-comment">// arr =&gt; [0, 1, 2]</span>
</code></pre>
<h5 id="&#x7EDF;&#x8BA1;&#x6570;&#x7EC4;&#x6210;&#x5458;&#x4E2A;&#x6570;"><a name="&#x7EDF;&#x8BA1;&#x6570;&#x7EC4;&#x6210;&#x5458;&#x4E2A;&#x6570;" class="anchor-navigation-ex-anchor" href="#&#x7EDF;&#x8BA1;&#x6570;&#x7EC4;&#x6210;&#x5458;&#x4E2A;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x7EDF;&#x8BA1;&#x6570;&#x7EC4;&#x6210;&#x5458;&#x4E2A;&#x6570;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr = [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">2</span>, <span class="hljs-number">2</span>];
<span class="hljs-keyword">const</span> count = arr.reduce(<span class="hljs-function">(<span class="hljs-params">t, v</span>) =&gt;</span> {
    t[v] = t[v] ? ++t[v] : <span class="hljs-number">1</span>;
    <span class="hljs-keyword">return</span> t;
}, {});
<span class="hljs-comment">// count =&gt; { 0: 1, 1: 2, 2: 3 }</span>
</code></pre>
<h5 id="&#x89E3;&#x6784;&#x6570;&#x7EC4;&#x6210;&#x5458;&#x5D4C;&#x5957;"><a name="&#x89E3;&#x6784;&#x6570;&#x7EC4;&#x6210;&#x5458;&#x5D4C;&#x5957;" class="anchor-navigation-ex-anchor" href="#&#x89E3;&#x6784;&#x6570;&#x7EC4;&#x6210;&#x5458;&#x5D4C;&#x5957;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x89E3;&#x6784;&#x6570;&#x7EC4;&#x6210;&#x5458;&#x5D4C;&#x5957;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr = [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, [<span class="hljs-number">2</span>, <span class="hljs-number">3</span>, [<span class="hljs-number">4</span>, <span class="hljs-number">5</span>]]];
<span class="hljs-keyword">const</span> [a, b, [c, d, [e, f]]] = arr;
<span class="hljs-comment">// a b c d e f =&gt; 0 1 2 3 4 5</span>
</code></pre>
<h5 id="&#x89E3;&#x6784;&#x6570;&#x7EC4;&#x6210;&#x5458;&#x522B;&#x540D;"><a name="&#x89E3;&#x6784;&#x6570;&#x7EC4;&#x6210;&#x5458;&#x522B;&#x540D;" class="anchor-navigation-ex-anchor" href="#&#x89E3;&#x6784;&#x6570;&#x7EC4;&#x6210;&#x5458;&#x522B;&#x540D;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x89E3;&#x6784;&#x6570;&#x7EC4;&#x6210;&#x5458;&#x522B;&#x540D;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr = [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>];
<span class="hljs-keyword">const</span> { <span class="hljs-number">0</span>: a, <span class="hljs-number">1</span>: b, <span class="hljs-number">2</span>: c } = arr;
<span class="hljs-comment">// a b c =&gt; 0 1 2</span>
</code></pre>
<h5 id="&#x89E3;&#x6784;&#x6570;&#x7EC4;&#x6210;&#x5458;&#x9ED8;&#x8BA4;&#x503C;"><a name="&#x89E3;&#x6784;&#x6570;&#x7EC4;&#x6210;&#x5458;&#x9ED8;&#x8BA4;&#x503C;" class="anchor-navigation-ex-anchor" href="#&#x89E3;&#x6784;&#x6570;&#x7EC4;&#x6210;&#x5458;&#x9ED8;&#x8BA4;&#x503C;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x89E3;&#x6784;&#x6570;&#x7EC4;&#x6210;&#x5458;&#x9ED8;&#x8BA4;&#x503C;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr = [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>];
<span class="hljs-keyword">const</span> [a, b, c = <span class="hljs-number">3</span>, d = <span class="hljs-number">4</span>] = arr;
<span class="hljs-comment">// a b c d =&gt; 0 1 2 4</span>
</code></pre>
<h5 id="&#x83B7;&#x53D6;&#x968F;&#x673A;&#x6570;&#x7EC4;&#x6210;&#x5458;"><a name="&#x83B7;&#x53D6;&#x968F;&#x673A;&#x6570;&#x7EC4;&#x6210;&#x5458;" class="anchor-navigation-ex-anchor" href="#&#x83B7;&#x53D6;&#x968F;&#x673A;&#x6570;&#x7EC4;&#x6210;&#x5458;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x83B7;&#x53D6;&#x968F;&#x673A;&#x6570;&#x7EC4;&#x6210;&#x5458;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr = [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>];
<span class="hljs-keyword">const</span> randomItem = arr[<span class="hljs-built_in">Math</span>.floor(<span class="hljs-built_in">Math</span>.random() * arr.length)];
<span class="hljs-comment">// randomItem =&gt; 1</span>
</code></pre>
<h5 id="&#x521B;&#x5EFA;&#x6307;&#x5B9A;&#x957F;&#x5EA6;&#x6570;&#x7EC4;"><a name="&#x521B;&#x5EFA;&#x6307;&#x5B9A;&#x957F;&#x5EA6;&#x6570;&#x7EC4;" class="anchor-navigation-ex-anchor" href="#&#x521B;&#x5EFA;&#x6307;&#x5B9A;&#x957F;&#x5EA6;&#x6570;&#x7EC4;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x521B;&#x5EFA;&#x6307;&#x5B9A;&#x957F;&#x5EA6;&#x6570;&#x7EC4;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr = [...new <span class="hljs-built_in">Array</span>(<span class="hljs-number">3</span>).keys()];
<span class="hljs-comment">// arr =&gt; [0, 1, 2]</span>
</code></pre>
<h5 id="&#x521B;&#x5EFA;&#x6307;&#x5B9A;&#x957F;&#x5EA6;&#x4E14;&#x503C;&#x76F8;&#x7B49;&#x7684;&#x6570;&#x7EC4;"><a name="&#x521B;&#x5EFA;&#x6307;&#x5B9A;&#x957F;&#x5EA6;&#x4E14;&#x503C;&#x76F8;&#x7B49;&#x7684;&#x6570;&#x7EC4;" class="anchor-navigation-ex-anchor" href="#&#x521B;&#x5EFA;&#x6307;&#x5B9A;&#x957F;&#x5EA6;&#x4E14;&#x503C;&#x76F8;&#x7B49;&#x7684;&#x6570;&#x7EC4;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x521B;&#x5EFA;&#x6307;&#x5B9A;&#x957F;&#x5EA6;&#x4E14;&#x503C;&#x76F8;&#x7B49;&#x7684;&#x6570;&#x7EC4;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Array</span>(<span class="hljs-number">3</span>).fill(<span class="hljs-number">0</span>);
<span class="hljs-comment">// arr =&gt; [0, 0, 0]</span>
</code></pre>
<h5 id="reduce&#x4EE3;&#x66FF;map&#x548C;filter"><a name="reduce&#x4EE3;&#x66FF;map&#x548C;filter" class="anchor-navigation-ex-anchor" href="#reduce&#x4EE3;&#x66FF;map&#x548C;filter"><i class="fa fa-link" aria-hidden="true"></i></a>reduce&#x4EE3;&#x66FF;map&#x548C;filter</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> _arr = [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>];

<span class="hljs-comment">// map</span>
<span class="hljs-keyword">const</span> arr = _arr.map(<span class="hljs-function"><span class="hljs-params">v</span> =&gt;</span> v * <span class="hljs-number">2</span>);
<span class="hljs-keyword">const</span> arr = _arr.reduce(<span class="hljs-function">(<span class="hljs-params">t, v</span>) =&gt;</span> {
    t.push(v * <span class="hljs-number">2</span>);
    <span class="hljs-keyword">return</span> t;
}, []);
<span class="hljs-comment">// arr =&gt; [0, 2, 4]</span>

<span class="hljs-comment">// filter</span>
<span class="hljs-keyword">const</span> arr = _arr.filter(<span class="hljs-function"><span class="hljs-params">v</span> =&gt;</span> v &gt; <span class="hljs-number">0</span>);
<span class="hljs-keyword">const</span> arr = _arr.reduce(<span class="hljs-function">(<span class="hljs-params">t, v</span>) =&gt;</span> {
    v &gt; <span class="hljs-number">0</span> &amp;&amp; t.push(v);
    <span class="hljs-keyword">return</span> t;
}, []);
<span class="hljs-comment">// arr =&gt; [1, 2]</span>

<span class="hljs-comment">// map&#x548C;filter</span>
<span class="hljs-keyword">const</span> arr = _arr.map(<span class="hljs-function"><span class="hljs-params">v</span> =&gt;</span> v * <span class="hljs-number">2</span>).filter(<span class="hljs-function"><span class="hljs-params">v</span> =&gt;</span> v &gt; <span class="hljs-number">2</span>);
<span class="hljs-keyword">const</span> arr = _arr.reduce(<span class="hljs-function">(<span class="hljs-params">t, v</span>) =&gt;</span> {
    v = v * <span class="hljs-number">2</span>;
    v &gt; <span class="hljs-number">2</span> &amp;&amp; t.push(v);
    <span class="hljs-keyword">return</span> t;
}, []);
<span class="hljs-comment">// arr =&gt; [4]</span>
</code></pre>
<h3 id="object-skill"><a name="object-skill" class="anchor-navigation-ex-anchor" href="#object-skill"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.7. Object Skill</h3>
<h5 id="&#x514B;&#x9686;&#x5BF9;&#x8C61;"><a name="&#x514B;&#x9686;&#x5BF9;&#x8C61;" class="anchor-navigation-ex-anchor" href="#&#x514B;&#x9686;&#x5BF9;&#x8C61;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x514B;&#x9686;&#x5BF9;&#x8C61;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> _obj = { <span class="hljs-attr">a</span>: <span class="hljs-number">0</span>, <span class="hljs-attr">b</span>: <span class="hljs-number">1</span>, <span class="hljs-attr">c</span>: <span class="hljs-number">2</span> }; <span class="hljs-comment">// &#x4EE5;&#x4E0B;&#x65B9;&#x6CD5;&#x4EFB;&#x9009;&#x4E00;&#x79CD;</span>
<span class="hljs-keyword">const</span> obj = { ..._obj };
<span class="hljs-keyword">const</span> obj = <span class="hljs-built_in">JSON</span>.parse(<span class="hljs-built_in">JSON</span>.stringify(_obj));
<span class="hljs-comment">// obj =&gt; { a: 0, b: 1, c: 2 }</span>
</code></pre>
<h5 id="&#x5408;&#x5E76;&#x5BF9;&#x8C61;"><a name="&#x5408;&#x5E76;&#x5BF9;&#x8C61;" class="anchor-navigation-ex-anchor" href="#&#x5408;&#x5E76;&#x5BF9;&#x8C61;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5408;&#x5E76;&#x5BF9;&#x8C61;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> obj1 = { <span class="hljs-attr">a</span>: <span class="hljs-number">0</span>, <span class="hljs-attr">b</span>: <span class="hljs-number">1</span>, <span class="hljs-attr">c</span>: <span class="hljs-number">2</span> };
<span class="hljs-keyword">const</span> obj2 = { <span class="hljs-attr">c</span>: <span class="hljs-number">3</span>, <span class="hljs-attr">d</span>: <span class="hljs-number">4</span>, <span class="hljs-attr">e</span>: <span class="hljs-number">5</span> };
<span class="hljs-keyword">const</span> obj = { ...obj1, ...obj2 };
<span class="hljs-comment">// obj =&gt; { a: 0, b: 1, c: 3, d: 4, e: 5 }</span>
</code></pre>
<h5 id="&#x5BF9;&#x8C61;&#x5B57;&#x9762;&#x91CF;"><a name="&#x5BF9;&#x8C61;&#x5B57;&#x9762;&#x91CF;" class="anchor-navigation-ex-anchor" href="#&#x5BF9;&#x8C61;&#x5B57;&#x9762;&#x91CF;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5BF9;&#x8C61;&#x5B57;&#x9762;&#x91CF;</h5>
<blockquote>
<p>&#x83B7;&#x53D6;&#x73AF;&#x5883;&#x53D8;&#x91CF;&#x65F6;&#x5FC5;&#x7528;&#x6B64;&#x65B9;&#x6CD5;&#xFF0C;&#x7528;&#x5B83;&#x4E00;&#x76F4;&#x723D;&#xFF0C;&#x4E00;&#x76F4;&#x7528;&#x5B83;&#x4E00;&#x76F4;&#x723D;</p>
</blockquote>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> env = <span class="hljs-string">&quot;prod&quot;</span>;
<span class="hljs-keyword">const</span> link = {
    <span class="hljs-attr">dev</span>: <span class="hljs-string">&quot;Development Address&quot;</span>,
    <span class="hljs-attr">test</span>: <span class="hljs-string">&quot;Testing Address&quot;</span>,
    <span class="hljs-attr">prod</span>: <span class="hljs-string">&quot;Production Address&quot;</span>
}[env];
<span class="hljs-comment">// link =&gt; &quot;Production Address&quot;</span>
</code></pre>
<h5 id="&#x5BF9;&#x8C61;&#x53D8;&#x91CF;&#x5C5E;&#x6027;"><a name="&#x5BF9;&#x8C61;&#x53D8;&#x91CF;&#x5C5E;&#x6027;" class="anchor-navigation-ex-anchor" href="#&#x5BF9;&#x8C61;&#x53D8;&#x91CF;&#x5C5E;&#x6027;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5BF9;&#x8C61;&#x53D8;&#x91CF;&#x5C5E;&#x6027;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> flag = <span class="hljs-literal">false</span>;
<span class="hljs-keyword">const</span> obj = {
    <span class="hljs-attr">a</span>: <span class="hljs-number">0</span>,
    <span class="hljs-attr">b</span>: <span class="hljs-number">1</span>,
    [flag ? <span class="hljs-string">&quot;c&quot;</span> : <span class="hljs-string">&quot;d&quot;</span>]: <span class="hljs-number">2</span>
};
<span class="hljs-comment">// obj =&gt; { a: 0, b: 1, d: 2 }</span>
</code></pre>
<h5 id="&#x521B;&#x5EFA;&#x7EAF;&#x7A7A;&#x5BF9;&#x8C61;"><a name="&#x521B;&#x5EFA;&#x7EAF;&#x7A7A;&#x5BF9;&#x8C61;" class="anchor-navigation-ex-anchor" href="#&#x521B;&#x5EFA;&#x7EAF;&#x7A7A;&#x5BF9;&#x8C61;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x521B;&#x5EFA;&#x7EAF;&#x7A7A;&#x5BF9;&#x8C61;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> obj = <span class="hljs-built_in">Object</span>.create(<span class="hljs-literal">null</span>);
<span class="hljs-built_in">Object</span>.prototype.a = <span class="hljs-number">0</span>;
<span class="hljs-comment">// obj =&gt; {}</span>
</code></pre>
<h5 id="&#x5220;&#x9664;&#x5BF9;&#x8C61;&#x65E0;&#x7528;&#x5C5E;&#x6027;"><a name="&#x5220;&#x9664;&#x5BF9;&#x8C61;&#x65E0;&#x7528;&#x5C5E;&#x6027;" class="anchor-navigation-ex-anchor" href="#&#x5220;&#x9664;&#x5BF9;&#x8C61;&#x65E0;&#x7528;&#x5C5E;&#x6027;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5220;&#x9664;&#x5BF9;&#x8C61;&#x65E0;&#x7528;&#x5C5E;&#x6027;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> obj = { <span class="hljs-attr">a</span>: <span class="hljs-number">0</span>, <span class="hljs-attr">b</span>: <span class="hljs-number">1</span>, <span class="hljs-attr">c</span>: <span class="hljs-number">2</span> }; <span class="hljs-comment">// &#x53EA;&#x60F3;&#x62FF;b&#x548C;c</span>
<span class="hljs-keyword">const</span> { a, ...rest } = obj;
<span class="hljs-comment">// rest =&gt; { b: 1, c: 2 }</span>
</code></pre>
<h5 id="&#x89E3;&#x6784;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x5D4C;&#x5957;"><a name="&#x89E3;&#x6784;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x5D4C;&#x5957;" class="anchor-navigation-ex-anchor" href="#&#x89E3;&#x6784;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x5D4C;&#x5957;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x89E3;&#x6784;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x5D4C;&#x5957;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> obj = { <span class="hljs-attr">a</span>: <span class="hljs-number">0</span>, <span class="hljs-attr">b</span>: <span class="hljs-number">1</span>, <span class="hljs-attr">c</span>: { <span class="hljs-attr">d</span>: <span class="hljs-number">2</span>, <span class="hljs-attr">e</span>: <span class="hljs-number">3</span> } };
<span class="hljs-keyword">const</span> { <span class="hljs-attr">c</span>: { d, e } } = obj;
<span class="hljs-comment">// d e =&gt; 2 3</span>
</code></pre>
<h5 id="&#x89E3;&#x6784;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x522B;&#x540D;"><a name="&#x89E3;&#x6784;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x522B;&#x540D;" class="anchor-navigation-ex-anchor" href="#&#x89E3;&#x6784;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x522B;&#x540D;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x89E3;&#x6784;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x522B;&#x540D;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> obj = { <span class="hljs-attr">a</span>: <span class="hljs-number">0</span>, <span class="hljs-attr">b</span>: <span class="hljs-number">1</span>, <span class="hljs-attr">c</span>: <span class="hljs-number">2</span> };
<span class="hljs-keyword">const</span> { a, <span class="hljs-attr">b</span>: d, <span class="hljs-attr">c</span>: e } = obj;
<span class="hljs-comment">// a d e =&gt; 0 1 2</span>
</code></pre>
<h5 id="&#x89E3;&#x6784;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x9ED8;&#x8BA4;&#x503C;"><a name="&#x89E3;&#x6784;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x9ED8;&#x8BA4;&#x503C;" class="anchor-navigation-ex-anchor" href="#&#x89E3;&#x6784;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x9ED8;&#x8BA4;&#x503C;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x89E3;&#x6784;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x9ED8;&#x8BA4;&#x503C;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> obj = { <span class="hljs-attr">a</span>: <span class="hljs-number">0</span>, <span class="hljs-attr">b</span>: <span class="hljs-number">1</span>, <span class="hljs-attr">c</span>: <span class="hljs-number">2</span> };
<span class="hljs-keyword">const</span> { a, b = <span class="hljs-number">2</span>, d = <span class="hljs-number">3</span> } = obj;
<span class="hljs-comment">// a b d =&gt; 0 1 3</span>
</code></pre>
<h3 id="function-skill"><a name="function-skill" class="anchor-navigation-ex-anchor" href="#function-skill"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.8. Function Skill</h3>
<h5 id="&#x51FD;&#x6570;&#x81EA;&#x6267;&#x884C;"><a name="&#x51FD;&#x6570;&#x81EA;&#x6267;&#x884C;" class="anchor-navigation-ex-anchor" href="#&#x51FD;&#x6570;&#x81EA;&#x6267;&#x884C;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x51FD;&#x6570;&#x81EA;&#x6267;&#x884C;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> Func = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}(); <span class="hljs-comment">// &#x5E38;&#x7528;</span>

(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{})(); <span class="hljs-comment">// &#x5E38;&#x7528;</span>
(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}()); <span class="hljs-comment">// &#x5E38;&#x7528;</span>
[<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}()];

+ <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}();
- <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}();
~ <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}();
! <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}();

<span class="hljs-keyword">new</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{};
<span class="hljs-keyword">new</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}();
<span class="hljs-keyword">void</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}();
<span class="hljs-keyword">typeof</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}();
<span class="hljs-keyword">delete</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}();

<span class="hljs-number">1</span>, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}();
<span class="hljs-number">1</span> ^ <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}();
<span class="hljs-number">1</span> &gt; <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}();
</code></pre>
<h5 id="&#x9690;&#x5F0F;&#x8FD4;&#x56DE;&#x503C;"><a name="&#x9690;&#x5F0F;&#x8FD4;&#x56DE;&#x503C;" class="anchor-navigation-ex-anchor" href="#&#x9690;&#x5F0F;&#x8FD4;&#x56DE;&#x503C;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x9690;&#x5F0F;&#x8FD4;&#x56DE;&#x503C;</h5>
<blockquote>
<p>&#x53EA;&#x80FD;&#x7528;&#x4E8E;<code>&#x5355;&#x8BED;&#x53E5;&#x8FD4;&#x56DE;&#x503C;&#x7BAD;&#x5934;&#x51FD;&#x6570;</code>&#xFF0C;&#x5982;&#x679C;&#x8FD4;&#x56DE;&#x503C;&#x662F;&#x5BF9;&#x8C61;&#x5FC5;&#x987B;&#x4F7F;&#x7528;<code>()</code>&#x5305;&#x4F4F;</p>
</blockquote>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> Func = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">name</span>) </span>{
    <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;I Love &quot;</span> + name;
};
<span class="hljs-comment">// &#x6362;&#x6210;</span>
<span class="hljs-keyword">const</span> Func = <span class="hljs-function"><span class="hljs-params">name</span> =&gt;</span> <span class="hljs-string">&quot;I Love &quot;</span> + name;
</code></pre>
<h5 id="&#x4E00;&#x6B21;&#x6027;&#x51FD;&#x6570;"><a name="&#x4E00;&#x6B21;&#x6027;&#x51FD;&#x6570;" class="anchor-navigation-ex-anchor" href="#&#x4E00;&#x6B21;&#x6027;&#x51FD;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E00;&#x6B21;&#x6027;&#x51FD;&#x6570;</h5>
<blockquote>
<p>&#x9002;&#x7528;&#x4E8E;&#x8FD0;&#x884C;&#x4E00;&#x4E9B;&#x53EA;&#x9700;&#x6267;&#x884C;&#x4E00;&#x6B21;&#x7684;&#x521D;&#x59CB;&#x5316;&#x4EE3;&#x7801;</p>
</blockquote>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Func</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;x&quot;</span>);
    Func = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;y&quot;</span>);
    }
}
</code></pre>
<h5 id="&#x60F0;&#x6027;&#x8F7D;&#x5165;&#x51FD;&#x6570;"><a name="&#x60F0;&#x6027;&#x8F7D;&#x5165;&#x51FD;&#x6570;" class="anchor-navigation-ex-anchor" href="#&#x60F0;&#x6027;&#x8F7D;&#x5165;&#x51FD;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x60F0;&#x6027;&#x8F7D;&#x5165;&#x51FD;&#x6570;</h5>
<blockquote>
<p>&#x51FD;&#x6570;&#x5185;&#x5224;&#x65AD;&#x5206;&#x652F;&#x8F83;&#x591A;&#x8F83;&#x590D;&#x6742;&#x65F6;&#x53EF;&#x5927;&#x5927;&#x8282;&#x7EA6;&#x8D44;&#x6E90;&#x5F00;&#x9500;</p>
</blockquote>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Func</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">if</span> (a === b) {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;x&quot;</span>);
    } <span class="hljs-keyword">else</span> {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;y&quot;</span>);
    }
}
<span class="hljs-comment">// &#x6362;&#x6210;</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Func</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">if</span> (a === b) {
        Func = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
            <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;x&quot;</span>);
        }
    } <span class="hljs-keyword">else</span> {
        Func = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
            <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;y&quot;</span>);
        }
    }
    <span class="hljs-keyword">return</span> Func();
}
</code></pre>
<h5 id="&#x68C0;&#x6D4B;&#x975E;&#x7A7A;&#x53C2;&#x6570;"><a name="&#x68C0;&#x6D4B;&#x975E;&#x7A7A;&#x53C2;&#x6570;" class="anchor-navigation-ex-anchor" href="#&#x68C0;&#x6D4B;&#x975E;&#x7A7A;&#x53C2;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x68C0;&#x6D4B;&#x975E;&#x7A7A;&#x53C2;&#x6570;</h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">IsRequired</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">&quot;param is required&quot;</span>);
}
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Func</span>(<span class="hljs-params">name = IsRequired(</span>)) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;I Love &quot;</span> + name);
}
Func(); <span class="hljs-comment">// &quot;param is required&quot;</span>
Func(<span class="hljs-string">&quot;You&quot;</span>); <span class="hljs-comment">// &quot;I Love You&quot;</span>
</code></pre>
<h5 id="&#x5B57;&#x7B26;&#x4E32;&#x521B;&#x5EFA;&#x51FD;&#x6570;"><a name="&#x5B57;&#x7B26;&#x4E32;&#x521B;&#x5EFA;&#x51FD;&#x6570;" class="anchor-navigation-ex-anchor" href="#&#x5B57;&#x7B26;&#x4E32;&#x521B;&#x5EFA;&#x51FD;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5B57;&#x7B26;&#x4E32;&#x521B;&#x5EFA;&#x51FD;&#x6570;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> Func = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Function</span>(<span class="hljs-string">&quot;name&quot;</span>, <span class="hljs-string">&quot;console.log(\&quot;I Love \&quot; + name)&quot;</span>);
</code></pre>
<h5 id="&#x4F18;&#x96C5;&#x5904;&#x7406;&#x9519;&#x8BEF;&#x4FE1;&#x606F;"><a name="&#x4F18;&#x96C5;&#x5904;&#x7406;&#x9519;&#x8BEF;&#x4FE1;&#x606F;" class="anchor-navigation-ex-anchor" href="#&#x4F18;&#x96C5;&#x5904;&#x7406;&#x9519;&#x8BEF;&#x4FE1;&#x606F;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4F18;&#x96C5;&#x5904;&#x7406;&#x9519;&#x8BEF;&#x4FE1;&#x606F;</h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">try</span> {
    Func();
} <span class="hljs-keyword">catch</span> (e) {
    location.href = <span class="hljs-string">&quot;https://stackoverflow.com/search?q=[js]+&quot;</span> + e.message;
}
</code></pre>
<h5 id="&#x4F18;&#x96C5;&#x5904;&#x7406;asyncawait&#x53C2;&#x6570;"><a name="&#x4F18;&#x96C5;&#x5904;&#x7406;asyncawait&#x53C2;&#x6570;" class="anchor-navigation-ex-anchor" href="#&#x4F18;&#x96C5;&#x5904;&#x7406;asyncawait&#x53C2;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4F18;&#x96C5;&#x5904;&#x7406;Async/Await&#x53C2;&#x6570;</h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">AsyncTo</span>(<span class="hljs-params">promise</span>) </span>{
    <span class="hljs-keyword">return</span> promise.then(<span class="hljs-function"><span class="hljs-params">data</span> =&gt;</span> [<span class="hljs-literal">null</span>, data]).catch(<span class="hljs-function"><span class="hljs-params">err</span> =&gt;</span> [err]);
}
<span class="hljs-keyword">const</span> [err, res] = <span class="hljs-keyword">await</span> AsyncTo(Func());
</code></pre>
<h5 id="&#x4F18;&#x96C5;&#x5904;&#x7406;&#x591A;&#x4E2A;&#x51FD;&#x6570;&#x8FD4;&#x56DE;&#x503C;"><a name="&#x4F18;&#x96C5;&#x5904;&#x7406;&#x591A;&#x4E2A;&#x51FD;&#x6570;&#x8FD4;&#x56DE;&#x503C;" class="anchor-navigation-ex-anchor" href="#&#x4F18;&#x96C5;&#x5904;&#x7406;&#x591A;&#x4E2A;&#x51FD;&#x6570;&#x8FD4;&#x56DE;&#x503C;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4F18;&#x96C5;&#x5904;&#x7406;&#x591A;&#x4E2A;&#x51FD;&#x6570;&#x8FD4;&#x56DE;&#x503C;</h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Func</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">Promise</span>.all([
        fetch(<span class="hljs-string">&quot;/user&quot;</span>),
        fetch(<span class="hljs-string">&quot;/comment&quot;</span>)
    ]);
}
<span class="hljs-keyword">const</span> [user, comment] = <span class="hljs-keyword">await</span> Func(); <span class="hljs-comment">// &#x9700;&#x5728;async&#x5305;&#x56F4;&#x4E0B;&#x4F7F;&#x7528;</span>
</code></pre>
<h3 id="dom-skill"><a name="dom-skill" class="anchor-navigation-ex-anchor" href="#dom-skill"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.9. DOM Skill</h3>
<h5 id="&#x663E;&#x793A;&#x5168;&#x90E8;dom&#x8FB9;&#x6846;"><a name="&#x663E;&#x793A;&#x5168;&#x90E8;dom&#x8FB9;&#x6846;" class="anchor-navigation-ex-anchor" href="#&#x663E;&#x793A;&#x5168;&#x90E8;dom&#x8FB9;&#x6846;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x663E;&#x793A;&#x5168;&#x90E8;DOM&#x8FB9;&#x6846;</h5>
<blockquote>
<p>&#x8C03;&#x8BD5;&#x9875;&#x9762;&#x5143;&#x7D20;&#x8FB9;&#x754C;&#x65F6;&#x4F7F;&#x7528;</p>
</blockquote>
<pre><code class="lang-javascript">[].forEach.call($$(<span class="hljs-string">&quot;*&quot;</span>), dom =&gt; {
    dom.style.outline = <span class="hljs-string">&quot;1px solid #&quot;</span> + (~~(<span class="hljs-built_in">Math</span>.random() * (<span class="hljs-number">1</span> &lt;&lt; <span class="hljs-number">24</span>))).toString(<span class="hljs-number">16</span>);
});
</code></pre>
<h5 id="&#x81EA;&#x9002;&#x5E94;&#x9875;&#x9762;"><a name="&#x81EA;&#x9002;&#x5E94;&#x9875;&#x9762;" class="anchor-navigation-ex-anchor" href="#&#x81EA;&#x9002;&#x5E94;&#x9875;&#x9762;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x81EA;&#x9002;&#x5E94;&#x9875;&#x9762;</h5>
<blockquote>
<p>&#x9875;&#x9762;&#x57FA;&#x4E8E;&#x4E00;&#x5F20;&#x8BBE;&#x8BA1;&#x56FE;&#x4F46;&#x9700;&#x505A;&#x591A;&#x6B3E;&#x673A;&#x578B;&#x81EA;&#x9002;&#x5E94;&#xFF0C;&#x5143;&#x7D20;&#x5C3A;&#x5BF8;&#x4F7F;&#x7528;<code>rem</code>&#x8FDB;&#x884C;&#x8BBE;&#x7F6E;</p>
</blockquote>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">AutoResponse</span>(<span class="hljs-params">width = <span class="hljs-number">750</span></span>) </span>{
    <span class="hljs-keyword">const</span> target = <span class="hljs-built_in">document</span>.documentElement;
    target.clientWidth &gt;= <span class="hljs-number">600</span>
        ? (target.style.fontSize = <span class="hljs-string">&quot;80px&quot;</span>)
        : (target.style.fontSize = target.clientWidth / width * <span class="hljs-number">100</span> + <span class="hljs-string">&quot;px&quot;</span>);
}
</code></pre>
<h5 id="&#x8FC7;&#x6EE4;xss"><a name="&#x8FC7;&#x6EE4;xss" class="anchor-navigation-ex-anchor" href="#&#x8FC7;&#x6EE4;xss"><i class="fa fa-link" aria-hidden="true"></i></a>&#x8FC7;&#x6EE4;XSS</h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">FilterXss</span>(<span class="hljs-params">content</span>) </span>{
    <span class="hljs-keyword">let</span> elem = <span class="hljs-built_in">document</span>.createElement(<span class="hljs-string">&quot;div&quot;</span>);
    elem.innerText = content;
    <span class="hljs-keyword">const</span> result = elem.innerHTML;
    elem = <span class="hljs-literal">null</span>;
    <span class="hljs-keyword">return</span> result;
}
</code></pre>
<h5 id="&#x5B58;&#x53D6;localstorage"><a name="&#x5B58;&#x53D6;localstorage" class="anchor-navigation-ex-anchor" href="#&#x5B58;&#x53D6;localstorage"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5B58;&#x53D6;LocalStorage</h5>
<blockquote>
<p>&#x53CD;&#x5E8F;&#x5217;&#x5316;&#x53D6;&#xFF0C;&#x5E8F;&#x5217;&#x5316;&#x5B58;</p>
</blockquote>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> love = <span class="hljs-built_in">JSON</span>.parse(localStorage.getItem(<span class="hljs-string">&quot;love&quot;</span>));
localStorage.setItem(<span class="hljs-string">&quot;love&quot;</span>, <span class="hljs-built_in">JSON</span>.stringify(<span class="hljs-string">&quot;I Love You&quot;</span>));
</code></pre>
<h3 id="&#x603B;&#x7ED3;"><a name="&#x603B;&#x7ED3;" class="anchor-navigation-ex-anchor" href="#&#x603B;&#x7ED3;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.10. &#x603B;&#x7ED3;</h3>
<p>&#x5199;&#x5230;&#x6700;&#x540E;&#x603B;&#x7ED3;&#x5F97;&#x5DEE;&#x4E0D;&#x591A;&#x4E86;&#xFF0C;&#x5982;&#x679C;&#x540E;&#x7EED;&#x6211;&#x60F3;&#x8D77;&#x8FD8;&#x6709;&#x54EA;&#x4E9B;&#x9057;&#x6F0F;&#x7684;<strong>JS&#x5F00;&#x53D1;&#x6280;&#x5DE7;</strong>&#xFF0C;&#x4F1A;&#x7EE7;&#x7EED;&#x5728;&#x8FD9;&#x7BC7;&#x6587;&#x7AE0;&#x4E0A;&#x8865;&#x5168;&#x3002;</p>
<p>&#x6700;&#x540E;&#x9001;&#x5927;&#x5BB6;&#x4E00;&#x4E2A;&#x952E;&#x76D8;&#xFF01;</p>
<pre><code class="lang-javascript">(<span class="hljs-function"><span class="hljs-params">_</span>=&gt;</span>[...<span class="hljs-string">&quot;`1234567890-=~~QWERTYUIOP[]\\~ASDFGHJKL;&apos;~~ZXCVBNM,./~&quot;</span>].map(<span class="hljs-function"><span class="hljs-params">x</span>=&gt;</span>(o+=<span class="hljs-string">`/<span class="hljs-subst">${b=<span class="hljs-string">&apos;_&apos;</span>.repeat(w=x&lt;y?<span class="hljs-number">2</span>:<span class="hljs-string">&apos; 667699&apos;</span>[x=[<span class="hljs-string">&quot;Bs&quot;</span>,<span class="hljs-string">&quot;Tab&quot;</span>,<span class="hljs-string">&quot;Caps&quot;</span>,<span class="hljs-string">&quot;Enter&quot;</span>][p++]||<span class="hljs-string">&apos;Shift&apos;</span>,p])}</span>\\|`</span>,m+=y+(x+<span class="hljs-string">&apos;    &apos;</span>).slice(<span class="hljs-number">0</span>,w)+y+y,n+=y+b+y+y,l+=<span class="hljs-string">&apos; __&apos;</span>+b)[<span class="hljs-number">73</span>]&amp;&amp;(k.push(l,m,n,o),l=<span class="hljs-string">&apos;&apos;</span>,m=n=o=y),m=n=o=y=<span class="hljs-string">&apos;|&apos;</span>,p=l=k=[])&amp;&amp;k.join<span class="hljs-string">`
`</span>)()
</code></pre>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; zhengyuliang all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x7F16;&#x5199;&#x65F6;&#x95F4;&#xFF1A;
2020-09-09 16:43:15
</span></footer></body></html>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="异步神器Async-await介绍与填坑.html" class="navigation navigation-prev " aria-label="Previous page: 异步神器Async Await介绍与填坑">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="编写高质量可维护的代码：一目了然的注释.html" class="navigation navigation-next " aria-label="Next page: 编写高质量可维护的代码：一目了然的注释">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"灵活运用JS开发技巧","level":"4.18","depth":1,"next":{"title":"编写高质量可维护的代码：一目了然的注释","level":"4.19","depth":1,"path":"javaScript/编写高质量可维护的代码：一目了然的注释.md","ref":"javaScript/编写高质量可维护的代码：一目了然的注释.md","articles":[]},"previous":{"title":"异步神器Async Await介绍与填坑","level":"4.17","depth":1,"path":"javaScript/异步神器Async-await介绍与填坑.md","ref":"javaScript/异步神器Async-await介绍与填坑.md","articles":[]},"dir":"ltr"},"config":{"plugins":["sectionx","splitter","tbfed-pagefooter","toggle-chapters","theme-comscore","-lunr","-search","search-plus","donate","anchor-navigation-ex","expandable-chapters","chapter-fold","expandable-chapters-small","livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy zhengyuliang","modify_label":"该文件编写时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"chapter-fold":{},"pluginsConfig":{"anchor-navigation-ex":{"showLevel":false,"showGoTop":true,"isRewritePageTitle":true,"isShowTocTitleIcon":true,"tocLevel1Icon":"fa fa-hand-o-right","tocLevel2Icon":"fa fa-hand-o-right","tocLevel3Icon":"fa fa-hand-o-right"}},"livereload":{},"splitter":{},"donate":{"title":"","button":"赏","wechat":"https://gitee.com/htzyl/img_bed/raw/master/pay/weixin-min.jpg","alipay":"https://gitee.com/htzyl/img_bed/raw/master/pay/alipay-min.jpg","wechatText":"微信打赏","alipayText":"支付宝打赏"},"fontsettings":{"theme":"white","family":"sans","size":2},"sectionx":{"tag":"b"},"highlight":{},"anchor-navigation-ex":{"showLevel":true,"associatedWithSummary":true,"mode":"float","showGoTop":true,"printLog":false,"multipleH1":true,"float":{"floatIcon":"fa fa-navicon","showLevelIcon":false,"level1Icon":"","level2Icon":"","level3Icon":""},"pageTop":{"showLevelIcon":false,"level1Icon":"","level2Icon":"","level3Icon":""}},"theme-comscore":{},"expandable-chapters-small":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"toggle-chapters":{},"expandable-chapters":{},"search-plus":{}},"theme":"default","author":"zhengyuliang","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"记录技术文档内容","language":"zh-hans","gitbook":">=3.0.0","description":"记录Gitbook的配置和一些插件的使用","theme-default":{"showLevel":true}},"file":{"path":"javaScript/灵活运用JS开发技巧.md","mtime":"2020-09-09T08:43:15.625Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-01-06T09:44:01.178Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sectionx/sectionx.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

